/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.dabarobjects.mobile.ui.models;

import com.dabarobjects.ui.surfaces.models.ControlTableModel;
import java.util.ArrayList;
import java.util.List;
import javax.bluetooth.RemoteDevice;

/**
 *
 * @author DabarObjects Solutions (www.dabarobjects.com)
 */
public class BluetoothDevicesTableModel extends ControlTableModel<RemoteDevice>{
    private List<RemoteDevice> devices;

    public BluetoothDevicesTableModel(List<RemoteDevice> devices) {
        this.devices = devices;
    }

    public BluetoothDevicesTableModel() {
        devices = new ArrayList<RemoteDevice>();
    }

    public List<RemoteDevice> getDevices() {
        return devices;
    }

    @Override
    public String loadContextHeadingFor(int rowIndex, int columnIndex) {
        RemoteDevice dv = devices.get(rowIndex);
        return dv.getBluetoothAddress();
    }

    @Override
    public Object loadValueAt(int rowIndex, int columnIndex) {
        RemoteDevice dv = devices.get(rowIndex);
        return dv;
    }

    public void setDevices(List<RemoteDevice> devices) {
        this.devices = devices;
        fireTableDataChanged();
    }

    @Override
    public int getRowCount() {
        return devices.size();
    }

    @Override
    public int getColumnCount() {
        return 1;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        RemoteDevice dv = devices.get(rowIndex);
        return dv.getBluetoothAddress();
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        return String.class;
    }

    @Override
    public String getColumnName(int column) {
        return "Device Address";
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

}
